

# 写一个函数 rand_verifiy_code()  每次返回一个由6位数字组成的随机验证码,验证码是字符串
import random

def rand_verifiy_code(length=6):
    # 方法1
    # code = random.randint(100000, 999999)
    # return str(code)
    # 方法2
    s = '0123456789'
    code = ''
    for x in range(length):
        code += random.choice(s)
    return code

if __name__ == '__main__':
    code = rand_verifiy_code()
    print('验证码：', code)